<?php include_once './application/views/sys_admin/common/header.php';  ?>
<div class=" definewidth m20">
<?php if(isset($admin['type_id']) && $admin['type_id'] !=1){?>
	<h2 style="color:red">对不起，权限不足</h2>
<?php }else{?>
	<form  class="form-inline definewidth m20">
	  		<button type="button" class="btn btn-success"  onclick="href('/sys_admin/systemadmin/admin_type_add_view/');" >添加管理员类型</button>
	 </form>
	<table class="table table-bordered table-hover definewidth m10">
		 <thead>
		    <tr>
		        <th><strong>ID</strong></th>
				<th><strong>类型名称</strong></th>
				<th width="70%"><strong>管理模块</strong></th>
				<th><strong>添加时间</strong></th>
				<th><strong>状态</strong></th>
				<th><strong>操作</strong></th>
		    </tr>
		   </thead>
		<?php foreach($type_list as $key=>$type){?>
		  <tr id="row_<?php echo $type['id'];?>">
			<td><?php echo $type['id'];?></td>
			<td><?php echo $type['name'];?></td>
			<td>
			<?php
			$type_arr = explode(',',$type['module']);
			foreach ($admintype as $k=>$v){
				foreach($v['list'] as  $sk =>$sv){
						if(array_key_exists(array_search($sk,$type_arr),$type_arr)){
							$mlist .= "[".$sv['linkname']."]-";
						}
				}
			}
			echo substr($mlist,0,-1);
			unset($mlist);
			?>
			</td>
			<td><?php echo date('Y-m-d H:i',$type['addtime']);?></td>
			<td><?php echo $type['status']==1?"开通":"关闭";?></td>
			<td><a href="/sys_admin/systemadmin/admin_type_edit_view/<?php echo $type['id'];?>">修改</a>  |<a href="javascript:if(confirm('确定删除？')){remove(<?php echo $type['id'];?>);}">删除</a></td>
		  </tr>
		<?php }?>
	  	<tr>
	  	<td colspan="8"  class="page"><?php echo $this->pagination->create_links();?></td>
		  	</tr>
	</table>
<?php }?>
</div>

<script>
function remove(id){
	$.ajax({
		type: "post",
		url: "/sys_admin/systemadmin/admin_type_del/",
		data: "id="+id,
		success: function(msg){
			$("#dialog" ).dialog();
			if(msg == 1){
				$("#msg").html("删除成功！");
				$("#row_"+id).hide();
			}else{
				$("#msg").html("删除失败，请联系管理员！");
			}
			setTimeout(function(){
				$("#dialog" ).dialog("close");
			},3000);
		},
		dataType: "text"
	});
}
</script>
<div id="dialog" title="系统提示" style="display:none"><p id="msg" style="text-align:center"></p></div>
